﻿using System;
using System.Web.Mvc;

namespace Avalon.Core.MVC.Attributes
{
    [AttributeUsage(AttributeTargets.Class, Inherited=true)]
    public class ViewModelAttribute : Attribute, IMetadataAware
    {
        public const string Key = "ViewModelAttribute";
        public Type DataModelType { get; set; }
        public string ViewRendererGroupName { get; set; }
        public string ViewRendererGroup { get; set; }

        public ViewModelAttribute(Type dataModelType)
        {
            DataModelType = dataModelType;
        }

        public void OnMetadataCreated(ModelMetadata metadata)
        {
            metadata.AdditionalValues[Key] = this;
        }
    }
}
